const superAgent = require("superagent");
function reqByKeywords(keywords) {
  return new Promise((resolve, reject) => {
    superAgent
      .get(encodeURI(`https://restapi.amap.com/v3/config/district?key=${tk}&keywords=${keywords}&subdistrict=1&extensions=all&offset=100`))
      .then((data) => {
        const res = JSON.parse(data.text);
        resolve(res.districts[0]);
      })
      .catch((err) => reject(err));
  });
}

module.exports = { reqByKeywords };
